﻿CREATE PROCEDURE [dbo].[sp_Get_LeadsByLeadBlockCode]
	@ZipID int
AS
	select l.[LeadID]
      ,l.[SelPersonID]
      ,l.[Zip]
      ,l.[ZipRequesterCode]
      ,l.[Division]
      ,l.[Market]
      ,l.[Territory]
      ,l.[Zip4]
      ,l.[CallType]
      ,l.[LeadType]
      ,l.[MdNumber]
      ,l.[SequenceNumber]
      ,l.[RawData]
      ,l.[City]
      ,l.[State]
      ,l.[County]
      ,l.[Latitude]
      ,l.[Longitude]
		from dbo.Zips z
		inner join dbo.Leads l on l.ZipRequesterCode = z.Zip
		where z.ZipID = @ZipID and l.LeadType in ('A', 'L')